package org.deltaset.samples.petclinic.domain;

import java.util.Set;
import java.util.HashSet;
import javax.persistence.Entity;
import javax.persistence.OneToMany;
import javax.persistence.CascadeType;

@Entity
public class Owner extends AbstractPerson {

    @OneToMany(cascade = CascadeType.ALL, mappedBy = "owner")
    private Set<Pet> pets = new HashSet<Pet>();

    public Set<Pet> getPets() {
        return this.pets;
    }

    public void setPets(Set<Pet> pets) {
        this.pets = pets;
    }

    @Override
    public String toString() {
        StringBuilder sb = new StringBuilder();
        sb.append("Address: ").append(getAddress()).append(", ");
        sb.append("BirthDay: ").append(getBirthDay()).append(", ");
        sb.append("City: ").append(getCity()).append(", ");
        sb.append("Email: ").append(getEmail()).append(", ");
        sb.append("FirstName: ").append(getFirstName()).append(", ");
        sb.append("HomePage: ").append(getHomePage()).append(", ");
        sb.append("Id: ").append(getId()).append(", ");
        sb.append("LastName: ").append(getLastName()).append(", ");
        sb.append("Pets: ").append(getPets() == null ? "null" : getPets().size()).append(", ");
        sb.append("Telephone: ").append(getTelephone()).append(", ");
        sb.append("Version: ").append(getVersion());
        return sb.toString();
    }
}
